import random
def random_ua():
    yue = ['01','02','03','04','05','06','07','08','09','10','11','12']
    ri = random.randint(1,29)
    day =f'0{ri}' if ri<10 else ri
    ua = 'Mozilla/5.0 (Windows NT {}.{}; WOW64; rv:21.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{}.0.{}.{} Safari/537.36'.format(random.randint(2,8),random.randint(0,10),random.randint(10,86),random.randint(999,8888),random.randint(0,500))
    ua0 = 'Mozilla/5.0 (Windows NT {}.{}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{}.0.{}.{} Safari/537.36'.format(random.randint(2,8),random.randint(0,10),random.randint(10,86),random.randint(999,8888),random.randint(0,500))
    ua1 = 'Mozilla/5.0 (Windows NT {}.{}; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{}.0.{}.{} Safari/537.36'.format(random.randint(2,8),random.randint(0,10),random.randint(10,86),random.randint(999,8888),random.randint(0,500))
    ua2 = 'Mozilla/5.0 (Windows NT {}.{}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{}.0.{}.{} Safari/537.36 Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/{}.{}.{} (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10'.format(random.randint(2,8),random.randint(0,10),random.randint(10,86),random.randint(999,8888),random.randint(0,500),random.randint(0,1000),random.randint(0,100),random.randint(0,100))
    ua3 = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{}.0.{}.{} Safari/537.36'.format(random.randint(10,86),random.randint(999,8888),random.randint(0,500))
    ua4 = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/{}{}{} Firefox/{}.0'.format(random.randint(2000,2020),random.choice(yue),day,random.randint(1,33))
    ua5 = 'Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/{}{}{} Firefox/{}.0'.format(random.randint(2000,2020),random.choice(yue),day,random.randint(1,33))
    ua6 = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{}.0.{}.{} Safari/537.36'.format(random.randint(10,86),random.randint(999,8888),random.randint(0,500))
    ua7 = 'Mozilla/5.0 (Windows NT {}.{}; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{}.0.{}.{} Safari/537.36'.format(random.randint(2,8),random.randint(0,10),random.randint(10,86),random.randint(999,8888),random.randint(0,500))
    ua_list = [ua,ua0,ua1,ua2,ua3,ua4,ua5,ua6,ua7]
    return random.choice(ua_list)
def random_mobile_ua():
    android_type = ['HMA-AL00 Build/HUAWEIHMA-AL00','V1818A Build/OPM1.171019.026','PCNM00 Build/PKQ1.190630.001','Lenovo L78051 Build/QKQ1.190825.002','MRD-AL00 Build/HUAWEIMRD-AL00',
                    'ARS-AL00 Build/HUAWEIARS-AL00','LND-AL40 Build/HONORLND-AL40','LYA-AL00 Build/HUAWEILYA-AL00','COL-AL10 Build/HUAWEICOL-AL10','FIG-TL10 Build/HUAWEIFIG-TL10',
                    'vivo X9s Plus Build/OPM1.171019.019','PIC-AL00 Build/HUAWEIPIC-AL00','HRY-AL00a Build/HONORHRY-AL00a','EVA-AL10 Build/HUAWEIEVA-AL10','GLK-AL00 Build/HUAWEIGLK-AL00',
                    ' V1818CT Build/O11019','Redmi Note 5 Build/PKQ1.180904.001','Redmi Note 8 Pro Build/PPR1.180610.011','COL-AL10 Build/HUAWEICOL-AL10','ONEPLUS A6010 Build/PKQ1.180716.001',
                    'MI 6 Build/NMF26X','MI 3 Build/NMF23X','MI 4 Build/NMF24X','MI 5 Build/NMF25X','MI 7 Build/NMF27X','MI 8 Build/QKQ1.190716.003','MI 8 SE Build/QKQ1.190828.002',
                    'MIX 2 Build/NMF26X','BKL-AL20 Build/HUAWEIBKL-AL20','16s Pro Build/PKQ1.190616.001','M1813 Build/O11019','MI 8 Build/QKQ1.190828.002','Mi Note 3 Build/PKQ1.181007.001',
                    'YAL-AL50 Build/HUAWEIYAL-AL50','MI 8 UD Build/QKQ1.190828.002','V1824A Build/QP1A.190711.020','PIC-AL00 Build/HUAWEIPIC-AL00','SNE-AL00 Build/HUAWEISNE-AL00',
                    'Lenovo Z90-7 Build/MMB29M','VOG-AL00 Build/HUAWEIVOG-AL00','MI MAX 3 Build/PKQ1.181007.001','TAS-AN00 Build/HUAWEITAS-AN00','vivo X9 Build/MMB29M','Redmi Note 8 Pro Build/PPR1.180610.011',
                    'CLT-AL00 Build/HUAWEICLT-AL00','Redmi 7 Build/PKQ1.181021.001','FLA-AL10 Build/HUAWEIFLA-AL10','Redmi Note 8 Pro Build/PPR1.180610.011','JSN-AL00 Build/HONORJSN-AL00',
                    'MIX 2 Build/PKQ1.190118.001','HWI-AL00 Build/HUAWEIHWI-AL00','PAAM00 Build/PKQ1.190414.001','V1813A Build/P00610','vivo X7 Build/LMY47V','JKM-AL00 Build/HUAWEIJKM-AL00',
                    'BAC-TL00 Build/HUAWEIBAC-TL00','vivo X6S A Build/LMY47V','vivo X21A Build/PKQ1.180819.001','MI 8 Build/QKQ1.190828.002','OPPO A57t Build/MMB29M','EVR-AL00 Build/HUAWEIEVR-AL00',
                    'EML-TL00 Build/HUAWEIEML-TL00','MI 6 Build/OPR1.170623.027','PCRM00 Build/QKQ1.191222.002','OPPO R9s Build/MMB29M','JKM-AL00 Build/HUAWEIJKM-AL00','V1911A Build/PKQ1.181030.001',
                    'Redmi K20 Pro Build/QKQ1.190825.002','OPPO R11s Build/NMF26X','PCNM00 Build/PKQ1.190630.001','V1809A Build/PKQ1.181030.001','Mi 10 Build/QKQ1.191117.002','MIX 2S Build/QKQ1.190828.002',
                    'V1901A Build/P00610','GM1900 Build/QKQ1.190716.003','ASK-AL00x Build/HONORASK-AL00x','BKL-AL20 Build/HUAWEIBKL-AL20','LIO-AN00 Build/HUAWEILIO-AN00','FRD-AL00 Build/HUAWEIFRD-AL00',
                    'V1913A Build/P00610','MIX 2S Build/QKQ1.190828.002','MHA-AL00 Build/HUAWEIMHA-AL00','vivo X6Plus D Build/LMY47I','CLT-AL01 Build/HUAWEICLT-AL01','PCT-AL10 Build/HUAWEIPCT-AL10',
                    'SM-G9500 Build/R16NW','Redmi Note 5 Build/OPM1.171019.011','vivo X21A Build/PKQ1.180819.001','OPPO R11 Plus Build/NMF26X','PACM00 Build/PPR1.180610.011','JKM-AL00b Build/HUAWEIJKM-AL00b',
                    'LYA-AL00 Build/HUAWEILYA-AL00','CLT-AL00 Build/HUAWEICLT-AL00','V1816A Build/OPM1.171019.011','MI 8 Build/PKQ1.180729.001','MI 9 Build/QKQ1.190828.002','BLA-TL00 Build/HUAWEIBLA-TL00']
    zhimu = 'QWERTYUIOPASDFGHJKLZXCVBNM'
    li = ['','1','2','3','4','5','6','7','8','9']
    li2 = ['','_1','_2','_3','_4','_5','_6','_7','_8','_9']
    # ua = 'Mozilla/5.0 (Linux; Android {0}.{1}.{2}; {3}; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/{4}.0 Chrome/{5}.0.{6}.{7} Mobile Safari/537.36 T7/{8}.{9} SP-engine/{10}.{11}.0 baiduboxapp/{8}.{9}.0.{12} (Baidu; P1 {0}.{1}.{2}){13}'.format(random.randint(7,10),random.randint(0,9),random.randint(0,9),random.choice(android_type),random.choice(['3','4']),random.randint(10,86),random.randint(999,8888),random.randint(0,500),random.randint(10,15),random.randint(10,30),random.randint(1,4),random.randint(1,20),random.randint(10,20),random.choice(['',' NABar/1.0']))
    # ua1 = 'Mozilla/5.0 (Linux; Android {0}; {1}; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/{2}.0 Chrome/{3}.0.{4}.{5} Mobile Safari/537.36 T7/{6}.{7} SP-engine/{8}.{9}.0 baiduboxapp/{6}.{7}.0.{10} (Baidu; P1 {0}){11}'.format(random.randint(7,10),random.choice(android_type),'4',random.randint(10,86),random.randint(999,8888),random.randint(0,500),random.randint(10,15),random.randint(10,30),random.randint(1,4),random.randint(1,20),random.randint(10,20),random.choice(['',' NABar/1.0']))
    ua2 = 'Mozilla/5.0 (Linux; U; Android {0}.{1}.{2}; zh-Hans-CN; {3}) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/{4}.0.{5}.{6} Quark/4.{7}.{8}.{9} Mobile Safari/537.36'.format(random.randint(7,10),random.randint(0,9),random.randint(0,9),random.choice(android_type),random.randint(10,86),random.randint(999,8888),random.randint(0,500),random.randint(0,10),random.randint(0,10),random.randint(0,200))
    ua3 = 'Mozilla/5.0 (Linux; U; Android {0}; zh-Hans-CN; {1}) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/{2}.0.{3}.{4} Quark/4.{5}.{6}.{7} Mobile Safari/537.36'.format(random.randint(7,10),random.choice(android_type),random.randint(10,86),random.randint(999,8888),random.randint(0,500),random.randint(0,10),random.randint(0,10),random.randint(0,200))
    ua4 = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS {0}_{1}{2} like Mac OS X; ja-jp) AppleWebKit/{3}.{4}.{5} (KHTML, like Gecko) Version/{6}.{7}.{8} Mobile/{9}{10}{11} Safari/{12}{13}.{14}'.format(random.randint(1,15),random.randint(0,7),random.choice(li2),random.randint(400,600),random.randint(1,20),random.randint(1,99),random.randint(3,7),random.randint(0,5),random.randint(0,5),random.randint(1,9),zhimu[random.randint(0,len(zhimu)-1)],random.randint(1,500),random.choice(li),random.randint(500,600),random.randint(1,20))
    ua_list = [ua2, ua3,ua4]
    return random.choice(ua_list)

if __name__ == '__main__':
    ua = random_mobile_ua()
    print(ua)